集群节点规划
| 角色 | 数量 | 推荐配置 |
|---|---|---|
| Master | 1-3 台 | 4核 8G,1TB 硬盘 |
| Worker | 2-N 台 | 4核 16G+ |
操作系统推荐 Ubuntu 20.04 或 22.04。
前置配置
1. 设置主机名和 IP
# 设置主机名
hostnamectl set-hostname master1
# 配置静态 IP
# /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
ens33:
addresses: [192.168.1.10/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 114.114.114.114]
bash
2. 配置 hosts 文件
# /etc/hosts
192.168.1.10 master1
192.168.1.11 worker1
192.168.1.12 worker2
192.168.1.13 worker3
bash
3. 时间同步
apt install -y chrony
systemctl enable --now chronyd
timedatectl set-ntp true
bash
4. 关闭 swap
# 临时关闭
swapoff -a
# 永久关闭
sed -i '/swap/d' /etc/fstab
bash
5. 内核参数配置
cat > /etc/sysctl.d/k8s.conf << 'EOF'
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
bash
↑